﻿using Application.DTO.Dictionary;
using Application.DTO;
using Application.Service.Dictionary;
using Domain.Entity.Dictionary;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using Application.IService.Dictionary;

namespace ApiServer.Controllers.Dictionary
{
    /// <summary>
    /// 字典明细控制器
    /// </summary>
    [Route("value")]
    [ApiController]
    public class DictionaryValueController : BaseController<DictionaryValue>
    {
        private readonly IDictionaryValueService dictionaryValueService;
        public DictionaryValueController(IDictionaryValueService dictionaryValueService):base(dictionaryValueService)
        {
            this.dictionaryValueService = dictionaryValueService;
        }
        /// <summary>
        /// 添加字典项
        /// </summary>
        /// <param name="dtos">字典项集合</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> InsertDictionaryValues(List<DictionaryValuesDTO> dtos)
        {
            return Ok(await dictionaryValueService.InsertDictionaryValues(dtos));
        }
        /// <summary>
        /// 修改字典项
        /// </summary>
        /// <param name="dtos">字典项集合</param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IActionResult> UpdateDictionaryValues(List<DictionaryValuesDTO> dtos)
        {
            return Ok(await dictionaryValueService.UpdateDictionaryValues(dtos));
        }
        /// <summary>
        /// 删除字典项，采用逻辑删除
        /// </summary>
        /// <param name="ids">字典项的ID值集合</param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<IActionResult> SoftDeleteDictionaryValues(string ids)
        {
            return Ok(await dictionaryValueService.SoftDeleteDictionaryValues(ids));
        }
        /// <summary>
        /// 查询字典项
        /// </summary>
        /// <param name="key">字典键ID</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> SearchDictionaryValues(int key)
        {
            return Ok(await dictionaryValueService.SearchDictionaryValues(key));
        }
    }
}
